 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:v="urn:schemas-microsoft-com:vml">
    <head>
      <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
      <title>actrex</title>
      
      <style type="text/css">
        @import url("http://www.google.com/uds/css/gsearch.css");
        @import url("http://www.google.com/uds/solutions/localsearch/gmlocalsearch.css");
  
        div.bubble{ font-size: x-small;
                    font-family: arial;}
      </style>
  
      
      <!-- rochester.edu key: ABQIAAAARQvhxpOK7xhWFXJtoYQk2hTD6QxZ77zRNmg2B6XFalpA3fyqABQjebCkSMPPjDuPgc4GbMAeSXHMyg //-->
      <script
      src="http://maps.google.com/maps?file=api&amp;v=3&amp;key=ABQIAAAA8mZlcc1JfFwUm7JyTJkSwhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxR_CHza8anVAVu0AtAtQ-bThviK0Q"
      type="text/javascript"></script>
  
      <script src="http://www.google.com/uds/api?file=uds.js&amp;v=1.0"
      type="text/javascript"></script> <script
      src="http://www.google.com/uds/solutions/localsearch/gmlocalsearch.js"
      type="text/javascript"></script>
  
  
      <script type="text/javascript">
      
      <!--
        var map;
        var geocoder;
        var address;
        var trafficInfo;
        var toggleState = 1;
        var addressMarker = null;
        
        %s
        
	function createMarker(point,html) {
	    var marker = new GMarker(point); GEvent.addListener(marker, "click",
	    function() {
	      marker.openInfoWindowHtml(html);
	    });
     
	    // The new marker "mouseover" listener
	    GEvent.addListener(marker,"mouseover", function() {
	      marker.openInfoWindowHtml(html);
	    });
    
	    // The new marker "mouseout" listener
	    GEvent.addListener(marker,"mouseout", function() {
	      marker.closeInfoWindow();
	    });
    
	    return marker;
	      }
	
	
	
	function getAddress(overlay, latlng) {
	  if (latlng != null) {
	    address = latlng;
            geocoder.getLocations(latlng, showAddress);
	  }
	}
        
        	
	function showAddress(response) {
          if (addressMarker != null) {
            map.removeOverlay(addressMarker);
          }
          if (!response || response.Status.code != 200) {
	    alert("Status Code:" + response.Status.code);
	  }
          else {
	    place = response.Placemark[0];
            point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]);
            addressMarker = new GMarker(point, {draggable: true, bouncy: true} );
            map.addOverlay(addressMarker);
            
            var htmlToDisplay =  '<div class="bubble"'+
		'<b>Click lat, lng: </b>' + response.name + '<br/>' +
                '<b>Address: </b><i>' + place.address + '</i><br>' +
                '<b>Projected lat, lng: </b>' + place.Point.coordinates[1] + ", " + place.Point.coordinates[0] + '<br>' +
		'<b>Status Code: </b>' + response.Status.code + ' ' + '<b>Status Request: </b>' + response.Status.request +
                ' ' + '<b>Accuracy: </b>' + place.AddressDetails.Accuracy + ' ' +
                '<b>Country code: </b> ' + place.AddressDetails.Country.CountryNameCode+'</div>';
                
            GEvent.addListener(addressMarker, "dragstart", function() {
              map.closeInfoWindow();
            });
            
            GEvent.addListener(addressMarker, "dragend", function() {
              addressMarker.openInfoWindowHtml(htmlToDisplay);
            });
               
            addressMarker.openInfoWindowHtml(htmlToDisplay);
            
           
            
	  }
		//showPaths();
	}
	
        
        function toggleTraffic() {
            if (toggleState == 1) {
              map.removeOverlay(trafficInfo);
              toggleState = 0;
            } else {
              map.addOverlay(trafficInfo);
              toggleState = 1;
            }
          }
      
      
       function initialize() {
	  if (GBrowserIsCompatible()) {
	    map = new GMap2(document.getElementById("map_canvas"));
    
	    var sw = new GLatLng(%s, %s ); var ne = new GLatLng(%s, %s );
	    
	    var bounds = new GLatLngBounds(sw, ne);
	    
	    map.setCenter(new GLatLng(%s, %s), map.getBoundsZoomLevel(bounds));
            //map.setMapType(G_HYBRID_MAP);
            map.setMapType(G_SATELLITE_MAP);
                
	    map.setUIToDefault(); map.addControl(new GLargeMapControl());
    
            map.addControl(new google.maps.LocalSearch(), new
	    GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(0,0)));
	    GSearch.setOnLoadCallback(initialize);
	    
	    GEvent.addListener(map, "click", getAddress); geocoder = new
	    GClientGeocoder();
    
            var trafficOptions = {incidents:true};
            trafficInfo = new GTrafficOverlay(trafficOptions);
            map.addOverlay(trafficInfo);
            
            // show CTF flag positions
            var flagNorth = new GLatLng(43.12703, -77.62932);
            var flagSouth = new GLatLng(43.12475, -77.62980);
            
            var basic = new GIcon(G_DEFAULT_ICON);
            //basic.shadow = "http://chart.apis.google.com/chart?chst=d_map_pin_shadow";
            basic.shadow = null;
            basic.iconSize = new GSize(25, 25);
            basic.iconAnchor = new GPoint(12, 12);
            //basic.shadowSize = new GSize(34, 25);
            basic.infoWindowAnchor = new GPoint(9, 10);
            
            var i1 = new GIcon(basic);
            //i1.image = "http://chart.apis.google.com/chart?chst=d_map_pin_icon&chld=snow|FFFFFF";
            i1.image = "img/casetta_green.png";
            var i2 = new GIcon(basic);
            i2.image = "img/casetta_yellow.png";
            
            var markerNorth = new GMarker(flagNorth, {icon: i1, draggable: false, bouncy: false});
            var markerSouth = new GMarker(flagSouth, {icon: i2, draggable: false, bouncy: false});
                                         
                                         
            GEvent.addListener(markerNorth,"mouseover", function() {
	      markerNorth.openInfoWindowHtml('<div class="bubble">North Flag</div>');
	    });
    	    GEvent.addListener(markerNorth,"mouseout", function() {
	      markerNorth.closeInfoWindow();
	    });
            
            GEvent.addListener(markerSouth,"mouseover", function() {
	      markerSouth.openInfoWindowHtml('<div class="bubble">South Flag</div>');
	    });
    	    GEvent.addListener(markerSouth,"mouseout", function() {
	      markerSouth.closeInfoWindow();
	    });
            
            map.addOverlay(markerNorth);
            map.addOverlay(markerSouth);    

	    showPaths();
    
	  }
	}
    
    
     function showPaths() {
	    //var point = new GLatLng(%s, %s);
            //var marker = createMarker(point,'<div class="bubble">GPS point info<br>This is the center of the minimal axis-aligned bounding rectangle of the paths</div>');
            //map.addOverlay(marker);
	    
	    %s
      }
    
      //-->
      </script>
      
    </head>
    
    <body onload="initialize()" onunload="GUnload()">
  
       <noscript><b>JavaScript must be enabled in order for you to use
        Google Maps.</b> However, it seems JavaScript is either disabled or not
        supported by your browser. To view Google Maps, enable JavaScript by
        changing your browser options, and then try again. </noscript>
      
      <script language="javascript">
          <!--
          
          var canvasHeight = window.innerHeight-20;
          document.write('<div id="map_canvas" style="width: 100%%; height:'+canvasHeight+'px; z-index:1; "></div>');
    
          //-->
      </script>
      
      <div style="z-index: 10000; position: absolute; right:13px; top:33px;">
        <input type="button" value="Traffic" onClick="toggleTraffic();"/>
      </div>
      
      
      
      
    </body>
  </html>
